<html>
<head><meta charset="utf-8"><title>macro call site in backtrace · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html">macro call site in backtrace</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212249611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212249611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212249611">(Oct 05 2020 at 00:52)</a>:</h4>
<p>Where do we retrieve the macro callsite for a span when generating debuginfo?</p>



<a name="212249638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212249638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212249638">(Oct 05 2020 at 00:53)</a>:</h4>
<p>e.g. writing</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">macro_rules</span><span class="o">!</span><span class="w"> </span><span class="n">print_it</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">"{:?}"</span><span class="p">,</span><span class="w"> </span><span class="n">Backtrace</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">print_it</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>shows the location of <code>print_it</code> in the backtrace, but I can't figure out where we compute that</p>



<a name="212269428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212269428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212269428">(Oct 05 2020 at 08:08)</a>:</h4>
<p>I believe what you are looking for is <code>render_multispan_macro_backtrace</code></p>



<a name="212331803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212331803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212331803">(Oct 05 2020 at 17:35)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> That looks like the comple-time backtrace shown for macro invocations. I'm interested in the runtime backtrace when a panic occurs</p>



<a name="212349492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212349492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212349492">(Oct 05 2020 at 20:04)</a>:</h4>
<p>Oh...</p>



<a name="212349510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212349510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212349510">(Oct 05 2020 at 20:04)</a>:</h4>
<p>Maybe it's using track_caller trickery?</p>



<a name="212357775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212357775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212357775">(Oct 05 2020 at 21:14)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs#L80">https://github.com/rust-lang/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs#L80</a></p>



<a name="212357802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212357802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212357802">(Oct 05 2020 at 21:14)</a>:</h4>
<p>this is likely what you were looking for</p>



<a name="212358195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macro%20call%20site%20in%20backtrace/near/212358195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macro.20call.20site.20in.20backtrace.html#212358195">(Oct 05 2020 at 21:19)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>